clear all
close all

%%PRKS
pdr95_pro_rd1 = GetStableRegionPdrArray('PRKS95_stable_pdr_rd1.txt');
pdr95_pro_rd2 = GetStableRegionPdrArray('PRKS95_stable_pdr_rd2.txt');
pdr95_pro_rd3 = GetStableRegionPdrArray('PRKS95_stable_pdr_rd3.txt');
pdr95_pro_rd4 = GetStableRegionPdrArray('PRKS95_stable_pdr_rd4.txt');
pdr95_pro_rd5 = GetStableRegionPdrArray('PRKS95_stable_pdr_rd5.txt');
pdr_pro_95 = [pdr95_pro_rd1; pdr95_pro_rd2;pdr95_pro_rd3; pdr95_pro_rd4; pdr95_pro_rd5];

pdr90_pro_rd1 = GetStableRegionPdrArray('PRKS90_stable_pdr_rd1.txt');
pdr90_pro_rd2 = GetStableRegionPdrArray('PRKS90_stable_pdr_rd2.txt');
pdr90_pro_rd3 = GetStableRegionPdrArray('PRKS90_stable_pdr_rd3.txt');
pdr90_pro_rd4 = GetStableRegionPdrArray('PRKS90_stable_pdr_rd4.txt');
pdr90_pro_rd5 = GetStableRegionPdrArray('PRKS90_stable_pdr_rd5.txt');
pdr_pro_90 = [pdr90_pro_rd1; pdr90_pro_rd2;pdr90_pro_rd3; pdr90_pro_rd4; pdr90_pro_rd5];

pdr80_pro_rd1 = GetStableRegionPdrArray('PRKS80_stable_pdr_rd1.txt');
pdr80_pro_rd2 = GetStableRegionPdrArray('PRKS80_stable_pdr_rd2.txt');
pdr80_pro_rd3 = GetStableRegionPdrArray('PRKS80_stable_pdr_rd3.txt');
pdr80_pro_rd4 = GetStableRegionPdrArray('PRKS80_stable_pdr_rd4.txt');
pdr80_pro_rd5 = GetStableRegionPdrArray('PRKS80_stable_pdr_rd5.txt');
pdr_pro_80 = [pdr80_pro_rd1; pdr80_pro_rd2;pdr80_pro_rd3; pdr80_pro_rd4; pdr80_pro_rd5];

pdr70_pro_rd1 = GetStableRegionPdrArray('PRKS70_stable_pdr_rd1.txt');
pdr70_pro_rd2 = GetStableRegionPdrArray('PRKS70_stable_pdr_rd2.txt');
pdr70_pro_rd3 = GetStableRegionPdrArray('PRKS70_stable_pdr_rd3.txt');
pdr70_pro_rd4 = GetStableRegionPdrArray('PRKS70_stable_pdr_rd4.txt');
pdr70_pro_rd5 = GetStableRegionPdrArray('PRKS70_stable_pdr_rd5.txt');
pdr_pro_70 = [pdr70_pro_rd1; pdr70_pro_rd2;pdr70_pro_rd3; pdr70_pro_rd4; pdr70_pro_rd5];


%%PRKS_L
pdr95_nopro_rd1 = GetStableRegionPdrArray('PRKS_L95_stable_pdr_rd1.txt');
pdr95_nopro_rd2 = GetStableRegionPdrArray('PRKS_L95_stable_pdr_rd2.txt');
pdr95_nopro_rd3 = GetStableRegionPdrArray('PRKS_L95_stable_pdr_rd3.txt');
pdr95_nopro_rd4 = GetStableRegionPdrArray('PRKS_L95_stable_pdr_rd4.txt');
pdr95_nopro_rd5 = GetStableRegionPdrArray('PRKS_L95_stable_pdr_rd5.txt');
pdr_nopro_95 = [pdr95_nopro_rd1; pdr95_nopro_rd2;pdr95_nopro_rd3; pdr95_nopro_rd4; pdr95_nopro_rd5];

pdr90_nopro_rd1 = GetStableRegionPdrArray('PRKS_L90_stable_pdr_rd1.txt');
pdr90_nopro_rd2 = GetStableRegionPdrArray('PRKS_L90_stable_pdr_rd2.txt');
pdr90_nopro_rd3 = GetStableRegionPdrArray('PRKS_L90_stable_pdr_rd3.txt');
pdr90_nopro_rd4 = GetStableRegionPdrArray('PRKS_L90_stable_pdr_rd4.txt');
pdr90_nopro_rd5 = GetStableRegionPdrArray('PRKS_L90_stable_pdr_rd5.txt');
pdr_nopro_90 = [pdr90_nopro_rd1; pdr90_nopro_rd2;pdr90_nopro_rd3; pdr90_nopro_rd4; pdr90_nopro_rd5];

pdr80_nopro_rd1 = GetStableRegionPdrArray('PRKS_L80_stable_pdr_rd1.txt');
pdr80_nopro_rd2 = GetStableRegionPdrArray('PRKS_L80_stable_pdr_rd2.txt');
pdr80_nopro_rd3 = GetStableRegionPdrArray('PRKS_L80_stable_pdr_rd3.txt');
pdr80_nopro_rd4 = GetStableRegionPdrArray('PRKS_L80_stable_pdr_rd4.txt');
pdr80_nopro_rd5 = GetStableRegionPdrArray('PRKS_L80_stable_pdr_rd5.txt');
pdr_nopro_80 = [pdr80_nopro_rd1; pdr80_nopro_rd2;pdr80_nopro_rd3; pdr80_nopro_rd4; pdr80_nopro_rd5];

pdr70_nopro_rd1 = GetStableRegionPdrArray('PRKS_L70_stable_pdr_rd1.txt');
pdr70_nopro_rd2 = GetStableRegionPdrArray('PRKS_L70_stable_pdr_rd2.txt');
pdr70_nopro_rd3 = GetStableRegionPdrArray('PRKS_L70_stable_pdr_rd3.txt');
pdr70_nopro_rd4 = GetStableRegionPdrArray('PRKS_L70_stable_pdr_rd4.txt');
pdr70_nopro_rd5 = GetStableRegionPdrArray('PRKS_L70_stable_pdr_rd5.txt');
pdr_nopro_70 = [pdr70_nopro_rd1; pdr70_nopro_rd2;pdr70_nopro_rd3; pdr70_nopro_rd4; pdr70_nopro_rd5];

%%PRKS_R
pdr95_p1_rd1 = GetStableRegionPdrArray('PRKS_R95_stable_pdr_rd1.txt');
pdr95_p1_rd2 = GetStableRegionPdrArray('PRKS_R95_stable_pdr_rd2.txt');
pdr95_p1_rd3 = GetStableRegionPdrArray('PRKS_R95_stable_pdr_rd3.txt');
pdr95_p1_rd4 = GetStableRegionPdrArray('PRKS_R95_stable_pdr_rd4.txt');
pdr95_p1_rd5 = GetStableRegionPdrArray('PRKS_R95_stable_pdr_rd5.txt');
pdr_p1_95 = [pdr95_p1_rd1; pdr95_p1_rd2;pdr95_p1_rd3; pdr95_p1_rd4; pdr95_p1_rd5];

pdr90_p1_rd1 = GetStableRegionPdrArray('PRKS_R90_stable_pdr_rd1.txt');
pdr90_p1_rd2 = GetStableRegionPdrArray('PRKS_R90_stable_pdr_rd2.txt');
pdr90_p1_rd3 = GetStableRegionPdrArray('PRKS_R90_stable_pdr_rd3.txt');
pdr90_p1_rd4 = GetStableRegionPdrArray('PRKS_R90_stable_pdr_rd4.txt');
pdr90_p1_rd5 = GetStableRegionPdrArray('PRKS_R90_stable_pdr_rd5.txt');
pdr_p1_90 = [pdr90_p1_rd1; pdr90_p1_rd2;pdr90_p1_rd3; pdr90_p1_rd4; pdr90_p1_rd5];

pdr80_p1_rd1 = GetStableRegionPdrArray('PRKS_R80_stable_pdr_rd1.txt');
pdr80_p1_rd2 = GetStableRegionPdrArray('PRKS_R80_stable_pdr_rd2.txt');
pdr80_p1_rd3 = GetStableRegionPdrArray('PRKS_R80_stable_pdr_rd3.txt');
pdr80_p1_rd4 = GetStableRegionPdrArray('PRKS_R80_stable_pdr_rd4.txt');
pdr80_p1_rd5 = GetStableRegionPdrArray('PRKS_R80_stable_pdr_rd5.txt');
pdr_p1_80 = [pdr80_p1_rd1; pdr80_p1_rd2;pdr80_p1_rd3; pdr80_p1_rd4; pdr80_p1_rd5];

pdr70_p1_rd1 = GetStableRegionPdrArray('PRKS_R70_stable_pdr_rd1.txt');
pdr70_p1_rd2 = GetStableRegionPdrArray('PRKS_R70_stable_pdr_rd2.txt');
pdr70_p1_rd3 = GetStableRegionPdrArray('PRKS_R70_stable_pdr_rd3.txt');
pdr70_p1_rd4 = GetStableRegionPdrArray('PRKS_R70_stable_pdr_rd4.txt');
pdr70_p1_rd5 = GetStableRegionPdrArray('PRKS_R70_stable_pdr_rd5.txt');
pdr_p1_70 = [pdr70_p1_rd1; pdr70_p1_rd2;pdr70_p1_rd3; pdr70_p1_rd4; pdr70_p1_rd5];

%%PRKS_RI
pdr95_p2_rd1 = GetStableRegionPdrArray('PRKS_RI95_stable_pdr_rd1.txt');
pdr95_p2_rd2 = GetStableRegionPdrArray('PRKS_RI95_stable_pdr_rd2.txt');
pdr95_p2_rd3 = GetStableRegionPdrArray('PRKS_RI95_stable_pdr_rd3.txt');
pdr95_p2_rd4 = GetStableRegionPdrArray('PRKS_RI95_stable_pdr_rd4.txt');
pdr95_p2_rd5 = GetStableRegionPdrArray('PRKS_RI95_stable_pdr_rd5.txt');
pdr_p2_95 = [pdr95_p2_rd1; pdr95_p2_rd2;pdr95_p2_rd3; pdr95_p2_rd4; pdr95_p2_rd5];

pdr90_p2_rd1 = GetStableRegionPdrArray('PRKS_RI90_stable_pdr_rd1.txt');
pdr90_p2_rd2 = GetStableRegionPdrArray('PRKS_RI90_stable_pdr_rd2.txt');
pdr90_p2_rd3 = GetStableRegionPdrArray('PRKS_RI90_stable_pdr_rd3.txt');
pdr90_p2_rd4 = GetStableRegionPdrArray('PRKS_RI90_stable_pdr_rd4.txt');
pdr90_p2_rd5 = GetStableRegionPdrArray('PRKS_RI90_stable_pdr_rd5.txt');
pdr_p2_90 = [pdr90_p2_rd1; pdr90_p2_rd2;pdr90_p2_rd3; pdr90_p2_rd4; pdr90_p2_rd5];

pdr80_p2_rd1 = GetStableRegionPdrArray('PRKS_RI80_stable_pdr_rd1.txt');
pdr80_p2_rd2 = GetStableRegionPdrArray('PRKS_RI80_stable_pdr_rd2.txt');
pdr80_p2_rd3 = GetStableRegionPdrArray('PRKS_RI80_stable_pdr_rd3.txt');
pdr80_p2_rd4 = GetStableRegionPdrArray('PRKS_RI80_stable_pdr_rd4.txt');
pdr80_p2_rd5 = GetStableRegionPdrArray('PRKS_RI80_stable_pdr_rd5.txt');
pdr_p2_80 = [pdr80_p2_rd1; pdr80_p2_rd2;pdr80_p2_rd3; pdr80_p2_rd4; pdr80_p2_rd5];

pdr70_p2_rd1 = GetStableRegionPdrArray('PRKS_RI70_stable_pdr_rd1.txt');
pdr70_p2_rd2 = GetStableRegionPdrArray('PRKS_RI70_stable_pdr_rd2.txt');
pdr70_p2_rd3 = GetStableRegionPdrArray('PRKS_RI70_stable_pdr_rd3.txt');
pdr70_p2_rd4 = GetStableRegionPdrArray('PRKS_RI70_stable_pdr_rd4.txt');
pdr70_p2_rd5 = GetStableRegionPdrArray('PRKS_RI70_stable_pdr_rd5.txt');
pdr_p2_70 = [pdr70_p2_rd1; pdr70_p2_rd2;pdr70_p2_rd3; pdr70_p2_rd4; pdr70_p2_rd5];




ALPHA = 0.05;
%dev =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_70) / sqrt(size(pdr_pro_70, 1));
%fprintf('[%.4f, %.4f]\n', mean(pdr_pro_70) - dev, mean(pdr_pro_70) + dev);

%% MEDIAN
%{
%MEADIAN = zeros(4,5);
MEADIAN = zeros(4,4);
Error_MEADIAN = zeros(4,4);
MEADIAN(1,1) = median(pdr_pro_70);
MEADIAN(1,2) = median(pdr_p1_70);
MEADIAN(1,3) = median(pdr_p2_70);
MEADIAN(1,4) = median(pdr_nopro_70);
Error_MEADIAN(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_70) / sqrt(size(pdr_pro_70, 1));
Error_MEADIAN(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_70) / sqrt(size(pdr_p1_70, 1));
Error_MEADIAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_70) / sqrt(size(pdr_p2_70, 1));
Error_MEADIAN(1,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_70) / sqrt(size(pdr_nopro_70, 1));
%MEADIAN(1,5) = median(pdr_rid_70);
MEADIAN(2,1) = median(pdr_pro_80);
MEADIAN(2,2) = median(pdr_p1_80);
MEADIAN(2,3) = median(pdr_p2_80);
MEADIAN(2,4) = median(pdr_nopro_80);
Error_MEADIAN(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_80) / sqrt(size(pdr_pro_80, 1));
Error_MEADIAN(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_80) / sqrt(size(pdr_p1_80, 1));
Error_MEADIAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_80) / sqrt(size(pdr_p2_80, 1));
Error_MEADIAN(2,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_80) / sqrt(size(pdr_nopro_80, 1));
%MEADIAN(2,5) = median(pdr_rid_80);
MEADIAN(3,1) = median(pdr_pro_90);
MEADIAN(3,2) = median(pdr_p1_90);
MEADIAN(3,3) = median(pdr_p2_90);
MEADIAN(3,4) = median(pdr_nopro_90);
Error_MEADIAN(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_90) / sqrt(size(pdr_pro_90, 1));
Error_MEADIAN(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_90) / sqrt(size(pdr_p1_90, 1));
Error_MEADIAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_90) / sqrt(size(pdr_p2_90, 1));
Error_MEADIAN(3,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_90) / sqrt(size(pdr_nopro_90, 1));
%MEADIAN(3,5) = median(pdr_rid_90);
MEADIAN(4,1) = median(pdr_pro_95);
MEADIAN(4,2) = median(pdr_p1_95);
MEADIAN(4,3) = median(pdr_p2_95);
MEADIAN(4,4) = median(pdr_nopro_95);
Error_MEADIAN(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_95) / sqrt(size(pdr_pro_95, 1));
Error_MEADIAN(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_95) / sqrt(size(pdr_p1_95, 1));
Error_MEADIAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_95) / sqrt(size(pdr_p2_95, 1));
Error_MEADIAN(4,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_95) / sqrt(size(pdr_nopro_95, 1));
%MEADIAN(4,5) = median(pdr_rid_95);
MEADIAN
Error_MEADIAN
figure;
handle = barweb(MEADIAN*100, Error_MEADIAN*100,1, ['70%'; '80%'; '90%'; '95%'], [''], ['PDR requirement'], ['Median PDR'], [1 1 1; 0.6 0.6 0.6; 0.15 0.15 0.15; 0 0 0]);
%legend ('PRKS','PRKS\_L','RID','PRKS\_R','PRKS\_RI');
handle.legend =legend ('PRKS','PRKS\_R  ','PRKS\_RI  ','PRKS\_L  ','orientation','horizontal');
%axh=get(gcf,'currentAxes')
%set(axh,'YGrid','on');
%{
handle.legend = gridLegend(handle.bars, 3, key,'location','North');
%}
set(gca, 'YTickLabel', sprintf('%d%%|', 0:50:100))
set(gca,'fontsize',60);
%ylim(0,2);
box on
maximize ();
saveas (gcf, 'median_pdr_all_prks_versions.jpg');
saveas (gcf, 'median_pdr_all_prks_versions.eps');
saveas (gcf, 'median_pdr_all_prks_versions.fig');
%}

%% MEAN
MEAN = zeros(4,3);
Error_MEAN=zeros(4,3);
MEAN(1,1) = mean(pdr_pro_70);
MEAN(1,2) = mean(pdr_p1_70);
%MEAN(1,3) = mean(pdr_p2_70);
MEAN(1,3) = mean(pdr_nopro_70);
Error_MEAN(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_70) / sqrt(size(pdr_pro_70, 1));
Error_MEAN(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_70) / sqrt(size(pdr_p1_70, 1));
%Error_MEAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_70) / sqrt(size(pdr_p2_70, 1));
Error_MEAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_70) / sqrt(size(pdr_nopro_70, 1));
%MEAN(1,5) = mean(pdr_rid_70);
MEAN(2,1) = mean(pdr_pro_80);
MEAN(2,2) = mean(pdr_p1_80);
%MEAN(2,3) = mean(pdr_p2_80);
MEAN(2,3) = mean(pdr_nopro_80);
Error_MEAN(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_80) / sqrt(size(pdr_pro_80, 1));
Error_MEAN(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_80) / sqrt(size(pdr_p1_80, 1));
%Error_MEAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_80) / sqrt(size(pdr_p2_80, 1));
Error_MEAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_80) / sqrt(size(pdr_nopro_80, 1));
%MEAN(2,5) = mean(pdr_rid_80);
MEAN(3,1) = mean(pdr_pro_90);
MEAN(3,2) = mean(pdr_p1_90);
%MEAN(3,3) = mean(pdr_p2_90);
MEAN(3,3) = mean(pdr_nopro_90);
Error_MEAN(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_90) / sqrt(size(pdr_pro_90, 1));
Error_MEAN(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_90) / sqrt(size(pdr_p1_90, 1));
%Error_MEAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_90) / sqrt(size(pdr_p2_90, 1));
Error_MEAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_90) / sqrt(size(pdr_nopro_90, 1));
%MEAN(3,5) = mean(pdr_rid_90);
MEAN(4,1) = mean(pdr_pro_95);
MEAN(4,2) = mean(pdr_p1_95);
%MEAN(4,3) = mean(pdr_p2_95);
MEAN(4,3) = mean(pdr_nopro_95);
Error_MEAN(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_95) / sqrt(size(pdr_pro_95, 1));
Error_MEAN(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_95) / sqrt(size(pdr_p1_95, 1));
%Error_MEAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_95) / sqrt(size(pdr_p2_95, 1));
Error_MEAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_95) / sqrt(size(pdr_nopro_95, 1));
%MEAN(4,5) = mean(pdr_rid_95);
MEAN
Error_MEAN
figure;
handle = barweb(MEAN*100, Error_MEAN*100,1, ['70%';'80%';'90%';'95%'], [], ['PDR requirement'], ['Mean PDR'],jet);
handle.legend =legend ('PRKS  ','PRKS\_R  ','PRKS\_L  ','orientation','horizontal');
set(gca, 'YTickLabel', sprintf('%d%%|', 80:10:100))
ylim([75,105]);
set(gca,'fontsize',60);
grid on;
box on;
maximize ();
[im_hatch, colorlist]=applyhatch_pluscolor(gcf, '/-.+x',1,[1 1 1 1 1],[],[],3,4);



%% STANDARD DEVIATION
%{
STD = zeros(4,4);
Error_STD = zeros(4,4);
STD(1,1) = std(pdr_pro_70);
STD(1,2) = std(pdr_p1_70);
STD(1,3) = std(pdr_p2_70);
STD(1,4) = std(pdr_nopro_70);
Error_STD(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_70) / sqrt(size(pdr_pro_70, 1));
Error_STD(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_70) / sqrt(size(pdr_p1_70, 1));
Error_STD(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_70) / sqrt(size(pdr_p2_70, 1));
Error_STD(1,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_70) / sqrt(size(pdr_nopro_70, 1));
%STD(1,5) = std(pdr_rid_70);
STD(2,1) = std(pdr_pro_80);
STD(2,2) = std(pdr_p1_80);
STD(2,3) = std(pdr_p2_80);
STD(2,4) = std(pdr_nopro_80);
Error_STD(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_80) / sqrt(size(pdr_pro_80, 1));
Error_STD(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_80) / sqrt(size(pdr_p1_80, 1));
Error_STD(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_80) / sqrt(size(pdr_p2_80, 1));
Error_STD(2,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_80) / sqrt(size(pdr_nopro_80, 1));
%STD(2,5) = std(pdr_rid_80);
STD(3,1) = std(pdr_pro_90);
STD(3,2) = std(pdr_p1_90);
STD(3,3) = std(pdr_p2_90);
STD(3,4) = std(pdr_nopro_90);
Error_STD(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_90) / sqrt(size(pdr_pro_90, 1));
Error_STD(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_90) / sqrt(size(pdr_p1_90, 1));
Error_STD(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_90) / sqrt(size(pdr_p2_90, 1));
Error_STD(3,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_90) / sqrt(size(pdr_nopro_90, 1));
%STD(3,5) = std(pdr_rid_90);
STD(4,1) = std(pdr_pro_95);
STD(4,2) = std(pdr_p1_95);
STD(4,3) = std(pdr_p2_95);
STD(4,4) = std(pdr_nopro_95);
Error_STD(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_95) / sqrt(size(pdr_pro_95, 1));
Error_STD(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_95) / sqrt(size(pdr_p1_95, 1));
Error_STD(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_95) / sqrt(size(pdr_p2_95, 1));
Error_STD(4,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_95) / sqrt(size(pdr_nopro_95, 1));
%STD(4,5) = std(pdr_rid_95);
STD
Error_STD
figure;

handle = barweb(STD*100, Error_STD*100,1, ['70%';'80%';'90%';'95%'], [''], ['PDR requirement'], ['Standard deviation'], [1 1 1; 0.7 0.7 0.7; 0.2 0.2 0.2; 0 0 0]);
handle.legend =legend ('PRKS  ','PRKS\_R  ','PRKS\_RI  ','PRKS\_L  ','orientation','horizontal');
set(gca, 'YTickLabel', sprintf('%d%%|', 0:5:10))
set(gca,'fontsize',60);
box on
maximize ();
%[im_hatch, colorlist]=applyhatch_pluscolor(gcf, '/-.+x',1,[1 1 1 1 1],[],[],3,4);
saveas(gcf,'std_pdr_all_prks_versions.fig');
saveas(gcf,'std_pdr_all_prks_versions.jpg');
saveas(gcf,'std_pdr_all_prks_versions.eps');
%}

%% BOXPLOT ALL PRKS VERSIONS
%{
%pdr_pro_70 = RemoveOutliers(pdr_pro_70, 0.7);
%pdr_pro_80 = RemoveOutliers(pdr_pro_80, 0.8);
%pdr_pro_90 = RemoveOutliers(pdr_pro_90, 0.9);
%pdr_pro_95 = RemoveOutliers(pdr_pro_95, 0.95);
%---------PDR 70%
figure;
%group = [repmat({'PRKS'}, size(pdr_pro_70), 1); repmat({'PRKS-R'}, size(pdr_p1_70), 1); repmat({'PRKS-RI'}, size(pdr_p2_70), 1); repmat({'PRKS-L'},size(pdr_nopro_70),1)];
group = [repmat({'PRKS'}, size(pdr_pro_70), 1); repmat({'PRKS-R'}, size(pdr_p2_70), 1); repmat({'PRKS-L'},size(pdr_nopro_70),1)];
boxplot(100*[pdr_pro_70;pdr_p1_70;pdr_nopro_70],group, 'notch','on');
maximize ();
set(gca,'xtick',[1 2 3],'xticklabel',{'PRKS','PRKS-R','PRKS-L'});
xlabel('PDR Requirement 70%');
ylabel('PDR');
%ylim([70 100]);
%set(gca, 'YTickLabel', sprintf('%d%%|', 60:10:100))
% saveas(gcf,'boxplot_req_70_all_prks_versions.fig');
% saveas(gcf,'boxplot_req_70_all_prks_versions.jpg');
% saveas(gcf,'boxplot_req_70_all_prks_versions.eps');


%---------PDR 80%
figure;
group = [repmat({'PRKS'}, size(pdr_pro_80), 1); repmat({'PRKS-R'}, size(pdr_p1_80), 1);  repmat({'PRKS-L'},size(pdr_nopro_80),1)];
boxplot(100*[pdr_pro_80;pdr_p1_80;pdr_nopro_80],group, 'notch','on');
maximize ();
set(gca,'xtick',[1 2 3],'xticklabel',{'PRKS','PRKS-R','PRKS-L'});
xlabel('PDR Requirement 80%');
ylabel('PDR');
%ylim([70 100]);
%set(gca, 'YTickLabel', sprintf('%d%%|', 75:5:100))
% saveas(gcf,'boxplot_req_80_all_prks_versions.fig');
% saveas(gcf,'boxplot_req_80_all_prks_versions.jpg');
% saveas(gcf,'boxplot_req_80_all_prks_versions.eps');


%---------PDR 90%
figure;
group = [repmat({'PRKS'}, size(pdr_pro_90), 1); repmat({'PRKS-R'}, size(pdr_p1_90), 1); repmat({'PRKS-L'},size(pdr_nopro_90),1)];
boxplot(100*[pdr_pro_90;pdr_p1_90;pdr_nopro_90],group, 'notch','on');
maximize ();
set(gca,'xtick',[1 2 3],'xticklabel',{'PRKS','PRKS-R','PRKS-L'});
xlabel('PDR Requirement 90%');
ylabel('PDR');
%ylim([70 100]);
%set(gca, 'YTickLabel', sprintf('%d%%|', 88:2:100))
% saveas(gcf,'boxplot_req_90_all_prks_versions.fig');
% saveas(gcf,'boxplot_req_90_all_prks_versions.jpg');
% saveas(gcf,'boxplot_req_90_all_prks_versions.eps');


%---------PDR 95%
figure;
group = [repmat({'PRKS'}, size(pdr_pro_95), 1); repmat({'PRKS-R'}, size(pdr_p1_95), 1); repmat({'PRKS-L'},size(pdr_nopro_95),1)];
boxplot(100*[pdr_pro_95;pdr_p1_95;pdr_nopro_95],group, 'notch','on');
maximize ();
set(gca,'xtick',[1 2 3 4],'xticklabel',{'PRKS','PRKS-R','PRKS-L'});
xlabel('PDR Requirement 95%');
ylabel('PDR');
%ylim([70 100]);
%set(gca, 'YTickLabel', sprintf('%d%%|', 94:1:100))
% saveas(gcf,'boxplot_req_95_all_prks_versions.fig');
% saveas(gcf,'boxplot_req_95_all_prks_versions.jpg');
% saveas(gcf,'boxplot_req_95_all_prks_versions.eps');


%{
Pos=[1.1 1.2 1.3 1.4  2.1 2.2 2.3 2.4 3.1 3.2 3.3 3.4 4.1 4.2 4.3 4.4];
XLab={'','','70%','','','','80%','','','','90%','','','','95%',''};
group = [repmat({'70_pro'}, size(pdr_pro_70), 1); repmat({'70_p1'}, size(pdr_p1_70), 1); repmat({'70_p2'}, size(pdr_p2_70), 1); repmat({'70_nopro'},size(pdr_nopro_70),1); ...
    repmat({'80_pro'}, size(pdr_pro_80), 1); repmat({'80_p1'}, size(pdr_p1_80), 1); repmat({'80_p2'}, size(pdr_p2_80), 1); repmat({'80_nopro'},size(pdr_nopro_80),1); ...
    repmat({'90_pro'}, size(pdr_pro_90), 1); repmat({'90_p1'}, size(pdr_p1_90), 1); repmat({'90_p2'}, size(pdr_p2_90), 1); repmat({'90_nopro'},size(pdr_nopro_90),1); ...
    repmat({'95_pro'}, size(pdr_pro_95), 1); repmat({'95_p1'}, size(pdr_p1_95), 1); repmat({'95_p2'}, size(pdr_p2_95), 1); repmat({'95_nopro'},size(pdr_nopro_95),1); ...
    ];
boxplot(100*[pdr_pro_70;pdr_p1_70;pdr_p2_70;pdr_nopro_70;  pdr_pro_80;pdr_p1_80;pdr_p2_80;pdr_nopro_80;  pdr_pro_90;pdr_p1_90;pdr_p2_90;pdr_nopro_90;  pdr_pro_95;pdr_p1_95;pdr_p2_95;pdr_nopro_95;], ...
    group,'positions',Pos,'labels',XLab,'notch','on');
%}
%}
